#ifndef _LT_GRAPHIC_H_
#define _LT_GRAPHIC_H_

#include "fastsig/fastsig.hpp"
#include "ltSingleton.h"

namespace Ogre
{
	class Root;
	class RenderWindow;
}

namespace Lotus
{
	enum RenderAPI
	{
		Direct3D9,
		OpenGL
	};

	class LOTUS_API GraphicManager: Utilities::Singleton<GraphicManager>, public Ogre::FrameListener
	{
	public:
		GraphicManager();		
		~GraphicManager();
		LT_DECLARE_SINGLETON(GraphicManager);
		/// Init width built-in config window
		bool init(const char* WindowTitle);
		/// Init width custom config
		bool init(RenderAPI api, const char* WindowTitle, unsigned int Width, unsigned int Height, bool FullScreen);
		/// Finish render loop
		void stopRendering();
		/// Get Ogre::Root
		Ogre::Root* getOgreRoot() const;
		/// Get the current render window
		Ogre::RenderWindow* getOgreRenderWindow() const;

		fastsig::signal<void (const Ogre::FrameEvent&)> FrameStartedEvent;
		fastsig::signal<void (const Ogre::FrameEvent&)> FrameRenderingQueuedEvent;
		fastsig::signal<void (const Ogre::FrameEvent&)> FrameEndedEvent;

	protected:
		virtual bool frameStarted(const Ogre::FrameEvent& evt);
		virtual bool frameRenderingQueued(const Ogre::FrameEvent& evt);
		virtual bool frameEnded(const Ogre::FrameEvent& evt);

		Ogre::Root* OgreRoot;
		Ogre::RenderWindow* OgreRenderWindow;

	private:
		void loadResources();
		bool run;
	};
}

#endif